package bb.lanxing.lib.devices.ble.ble.characteristic.light;

import java.nio.ByteBuffer;
import kotlin.Metadata;
import kotlin.collections.ArraysKt;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;

public final class LightControlPointResult {
    public static final Companion Companion = new Companion(null);
    private final LightControlPointOpCode requestOpCode;
    private final LightControlPointOpCode responseOpCode;
    private final byte[] responseParameter;
    private final LightControlPointResultOpCode resultOpCode;

    public LightControlPointResult(LightControlPointOpCode responseOpCode, LightControlPointOpCode requestOpCode, LightControlPointResultOpCode resultOpCode, byte[] responseParameter) {
        Intrinsics.checkNotNullParameter(responseOpCode, "responseOpCode");
        Intrinsics.checkNotNullParameter(requestOpCode, "requestOpCode");
        Intrinsics.checkNotNullParameter(resultOpCode, "resultOpCode");
        Intrinsics.checkNotNullParameter(responseParameter, "responseParameter");
        this.responseOpCode = responseOpCode;
        this.requestOpCode = requestOpCode;
        this.resultOpCode = resultOpCode;
        this.responseParameter = responseParameter;
    }

    public /* synthetic */ LightControlPointResult(LightControlPointOpCode lightControlPointOpCode, LightControlPointOpCode lightControlPointOpCode2, LightControlPointResultOpCode lightControlPointResultOpCode, byte[] bArr, int i, DefaultConstructorMarker defaultConstructorMarker) {
        this((i & 1) != 0 ? LightControlPointOpCode.unknown : lightControlPointOpCode, lightControlPointOpCode2, lightControlPointResultOpCode, bArr);
    }

    public LightControlPointOpCode getResponseOpCode() {
        return this.responseOpCode;
    }

    public LightControlPointOpCode getRequestOpCode() {
        return this.requestOpCode;
    }

    public LightControlPointResultOpCode getResultOpCode() {
        return this.resultOpCode;
    }

    public byte[] getResponseParameter() {
        return this.responseParameter;
    }

    public byte[] convertByteArray() {
        byte[] array = ByteBuffer.allocate(this.responseParameter.length + 3).put((byte) this.responseOpCode.getValue()).put((byte) this.requestOpCode.getValue()).put((byte) this.resultOpCode.getValue()).put(this.responseParameter).array();
        Intrinsics.checkNotNullExpressionValue(array, "allocate(responseParamet…esponseParameter).array()");
        return array;
    }


    public static final class Companion {
        public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
            this();
        }

        private Companion() {
        }

        public LightControlPointResult fromByteArray(byte[] byteArray) {
            Intrinsics.checkNotNullParameter(byteArray, "byteArray");
            return new LightControlPointResult(LightControlPointOpCode.Companion.from(byteArray[0]), LightControlPointOpCode.Companion.from(byteArray[1]), LightControlPointResultOpCode.Companion.from(byteArray[2]), byteArray.length > 3 ? ArraysKt.copyOfRange(byteArray, 3, byteArray.length - 1) : new byte[0]);
        }
    }
}
